package com.gp.ajax.app1;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class ValiateUserNameServlet extends javax.servlet.http.HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");
        request.setCharacterEncoding("UTF-8");
        String s=null;
        if("admin".equals(username)){
            s="<front style='color:red'>用户名已经存在</front>";
        }else{
             s="<front style='color:black'>用户名可以使用</front>";
        }
        response.setContentType("text/html;Charset=UTF-8");
        PrintWriter writer = response.getWriter();
        writer.print(s);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
